package com.dong.bean;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanNameAware;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;

import javax.annotation.PostConstruct;

/**
 * description
 *
 * @author Administrator 2021/08/30 15:27
 */
public class MyBeanNameAware implements BeanNameAware, ApplicationContextAware, InitializingBean {

    private static ApplicationContext context;

    public MyBeanNameAware(){
        System.out.println("构造函数");
    }

    @PostConstruct
    public void postConstruct(){
        System.out.println("postConstruct");
    }

    public void init(){
        System.out.println("init方法");
    }

    @Override
    public void setBeanName(String s) {
        System.out.println("setBeanName: "+ s);
    }

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        System.out.println("ApplicationContext");
        context = applicationContext;
    }

    @Override
    public void afterPropertiesSet() throws Exception {
        System.out.println("afterPropertiesSet");
    }
}
